/*
	Code almost entirely stolen from http://jsninja.com/. Great book.
*/
Skink.Timers = {
    timerID: -1,
    timers: [],
    start: function() {
        if (Skink.Timers.timerID > -1) {
            return;
        }
        air.trace(Skink.Timers.timerID);
        (function() {
            for (var i = 0; i < Skink.Timers.timers.length; i++) {
                if (Skink.Timers.timers[i]() === false) {
                    Skink.Timers.timers.splice(i, 1);
                    i--;
                }
            }
            Skink.Timers.timerID = setTimeout(arguments.callee, 0);
        })();
    },
    stop: function() {
        clearTimeout(Skink.Timers.timerID);
        Skink.Timers.timerID = -1;
    },
    add: function(fn) {
        Skink.Timers.timers.push(fn);
        Skink.Timers.start();
    }
};